"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var HmacSHA1 = require("./crypto-js/hmac-sha1");
var Base64 = require("./crypto-js/enc-base64");
var SignerS3 = /** @class */ (function() {
  function SignerS3(credentials) {
    this.Creds = credentials;
  }
  SignerS3.prototype.HMACSha1Base64 = function(key, text) {
    var hashDigest = HmacSHA1(text, key);
    return Base64.stringify(hashDigest);
  };
  SignerS3.prototype.GetStringToSign = function(httpVerb, contentType, acl, date, uri) {
    return `${httpVerb}\n\n${contentType}\n\n${acl? 'x-amz-acl:' + acl + '\n': ''}x-amz-date:${date}\nx-amz-user-agent:aws-sdk-js/2.100.0 callback\n${uri}`
  };
  SignerS3.prototype.AuthorizationSignature = function(httpVerb, contentType, date, uri) {
    return this.AuthorizationSignatureWithAcl(httpVerb, contentType, "", date, uri);
  };
  SignerS3.prototype.AuthorizationSignatureWithAcl = function(httpVerb, contentType, acl, date, uri) {
    var stringToSign = this.GetStringToSign(httpVerb, contentType, acl, date, uri);
    var signature = this.HMACSha1Base64(this.Creds.SecretAccessKey, stringToSign);
    console.log("stringToSign: ");
    console.log("signature: ", signature);
    return "AWS " + this.Creds.AccessKeyId + ":" + signature;
  };
  return SignerS3;
}());
exports.SignerS3 = SignerS3;
